import instance from "@/http/index.js"


// 注册
export const registerAPI = (data) => {
  const { account, password } = data
  return instance({
    url: "/api/register",
    method: "post",
    data: {
      account,
      password
    }
  })
}

// 登录
export const loginAPI = (data) => {
  const { account, password } = data
  return instance({
    url: "/api/login",
    method: "post",
    data: {
      account,
      password
    }
  })
}

// 忘记密码 -- 验证账号邮箱
export const verifyAPI = (data) => {
  const { account, email } = data
  return instance({
    url: `/api/checkAccountAndEmail`,
    method: "post",
    data: {
      account,
      email
    }
  })
}

// 忘记密码 -- 重置密码
export const resetAPI = (data) => {
  const { id, newPassword } = data
  return instance({
    url: `/api/updatePasswordByAccount`,
    method: "post",
    data: {
      id,
      newPassword
    }
  })
}

export const getRouterByIdAPI = (data) => {
  const { id } = data
  return instance({
    url: `/api/getRouterById`,
    method: "post",
    data: { id }
  })
}